package model

import (
	"time"
)

type User struct {
	UserID     int64     `gorm:"primaryKey;autoIncrement"`
	CardNumber int64     `gorm:"not null"`
	RuleNumber int32     `gorm:"not null"`
	Status     int32     `gorm:"not null"`
	Username   string    `gorm:"size:32;not null"`
	Password   string    `gorm:"size:64;not null"`
	CardName   string    `gorm:"size:10;not null"`
	CreateTime time.Time `gorm:"not null"`
	UpdateTime time.Time `gorm:"autoUpdateTime"`
}

func (u *User) TableName() string {
	return "t_users"
}

type UserBook struct {
	BookID          int32     `gorm:"primaryKey;autoIncrement;column:book_id" json:"bookID"`
	BookNumber      int64     `gorm:"not null;column:book_number" json:"bookNumber"`
	BookName        string    `gorm:"size:32;not null;column:book_name" json:"bookName"`
	BookAuthor      string    `gorm:"size:32;not null;column:book_author" json:"bookAuthor"`
	BookLibrary     string    `gorm:"size:32;not null;column:book_library" json:"bookLibrary"`
	BookType        string    `gorm:"size:32;not null;column:book_type" json:"bookType"`
	BookLocation    string    `gorm:"size:32;not null;column:book_location" json:"bookLocation"`
	BookStatus      string    `gorm:"size:32;not null;column:book_status" json:"bookStatus"`
	BookDescription string    `gorm:"size:255;not null;column:book_description" json:"bookDescription"`
	CreateTime      time.Time `gorm:"not null;column:create_time" json:"createTime"`
	UpdateTime      time.Time `gorm:"not null;autoUpdateTime;column:update_time" json:"updateTime"`
}

func (b *UserBook) TableName() string {
	return "t_books"
}

type UserRule struct {
	RuleID           int32     `gorm:"primaryKey;autoIncrement;column:rule_id" json:"ruleID"`
	BookDays         int32     `gorm:"column:book_days" json:"bookDays"`
	BookLimitNumber  int32     `gorm:"column:book_limit_number" json:"bookLimitNumber"`
	BookRuleID       int64     `gorm:"column:book_rule_id" json:"bookRuleID"`
	BookLimitLibrary string    `gorm:"column:book_limit_library" json:"bookLimitLibrary"`
	BookOverdueFee   float64   `gorm:"column:book_overdue_fee" json:"bookOverdueFee"`
	CreateTime       time.Time `gorm:"not null;column:create_time" json:"createTime"`
	UpdateTime       time.Time `gorm:"not null;autoUpdateTime;column:update_time" json:"updateTime"`
}

func (r *UserRule) TableName() string {
	return "t_book_rule"
}

type UserNotice struct {
	NoticeID      int32     `gorm:"primaryKey;autoIncrement;column:notice_id" json:"noticeID"`
	NoticeTitle   string    `gorm:"size:32;not null;column:notice_title" json:"noticeTitle"`
	NoticeContent string    `gorm:"size:255;not null;column:notice_content" json:"noticeContent"`
	NoticeAdminID int64     `gorm:"not null;column:notice_admin_id" json:"noticeAdminID"`
	CreateTime    time.Time `gorm:"not null;column:create_time" json:"createTime"`
	UpdateTime    time.Time `gorm:"not null;autoUpdateTime;column:update_time" json:"updateTime"`
}

func (n *UserNotice) TableName() string {
	return "t_notice"
}

type UserBorrow struct {
	BorrowID   int32     `gorm:"primaryKey;autoIncrement;column:borrow_id" json:"borrowID"`
	CardNumber int64     `gorm:"not null;column:card_number" json:"cardNumber"`
	BookNumber int64     `gorm:"not null;column:book_number" json:"bookNumber"`
	BorrowDate time.Time `gorm:"not null;column:borrow_date" json:"borrowDate"`
	CloseDate  time.Time `gorm:"not null;column:close_date" json:"closeDate"`
	ReturnDate time.Time `gorm:"column:return_date" json:"returnDate"`
	CreateTime time.Time `gorm:"not null;column:create_time" json:"createTime"`
	UpdateTime time.Time `gorm:"not null;autoUpdateTime;column:update_time" json:"updateTime"`
}

func (b *UserBorrow) TableName() string {
	return "t_books_borrow"
}

type UserViolation struct {
	ViolationID      int32     `gorm:"primaryKey;autoIncrement;column:violation_id" json:"violationID"`
	CardNumber       int64     `gorm:"not null;column:card_number" json:"cardNumber"`
	BookNumber       int64     `gorm:"not null;column:book_number" json:"bookNumber"`
	ViolationAdminId int64     `gorm:"not null;column:violation_admin_id" json:"violationAdminId"`
	ViolationMessage string    `gorm:"size:100;column:violation_message" json:"violationMessage"`
	BorrowDate       time.Time `gorm:"not null;column:borrow_date" json:"borrowDate"`
	CloseDate        time.Time `gorm:"not null;column:close_date" json:"closeDate"`
	ReturnDate       time.Time `gorm:"column:return_date" json:"returnDate"`
	CreateTime       time.Time `gorm:"not null;column:create_time" json:"createTime"`
	UpdateTime       time.Time `gorm:"not null;autoUpdateTime;column:update_time" json:"updateTime"`
}

func (v *UserViolation) TableName() string {
	return "t_violation"
}

type UserComment struct {
	CommentID      int32     `gorm:"primaryKey;autoIncrement;column:comment_id" json:"commentID"`
	UserID         int64     `gorm:"not null;column:user_id" json:"userID"`
	CommentMessage string    `gorm:"size:255;not null;column:comment_message" json:"commentMessage"`
	CreateTime     time.Time `gorm:"not null;column:create_time" json:"createTime"`
	UpdateTime     time.Time `gorm:"not null;autoUpdateTime;column:update_time" json:"updateTime"`
}

func (c *UserComment) TableName() string {
	return "t_comment"
}
